<?php
declare (strict_types = 1);

namespace app\admin\controller;

use think\facade\Db;
use think\facade\View;
use think\facade\Request;

class cate
{

    public function cate()
    {
        $list=Db::table('ecm_gcategory')->field('parent_id')->select();
        $abc=[];
        foreach ($list as $v) {
            $abc[]=$v['parent_id'];
        }
        $a=Request::get('cid');
        if(empty($a)){
            $rt=Db::table('ecm_gcategory')->where('parent_id','=',0)
                ->order('sort_order desc')->select();
        }else{
            $rt=Db::table('ecm_gcategory')->where('parent_id','=',$a)
                ->order('sort_order desc')->select();
        }
        View::assign("list",$abc);
        View::assign('rt',$rt);
        return View::fetch();
    }
//    public function cate2()
//    {
//        $id=isset($_GET['id'])?$_GET['id']:'';
//        $list=Db::table('ecm_gcategory')
//            ->where("parent_id",'=',$id)
//            ->select();
//        if($list->isEmpty()){
//            View::assign('empty',"<p>暂无数据</p>");
//            View::assign('list',$list->toArray());
//        }else{
//            View::assign('list',$list->toArray());
//        }
//
//        return View::fetch();
//    }

}

